package com.qf.qfdrivermqtt.controller;

import com.qf.common.bean.R;
import com.qf.common.dto.DriverMqttDto;
import com.qf.qfdrivermqtt.service.AuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/driver")
@Slf4j
public class AuthController {

    @Autowired
    private AuthService authService;

    /**
     * 大鹏设备向该资源发起登录认证
     *  一旦登录成功，需要向大鹏设备返回emqx连接需要的信息
     * @return
     */
    @PostMapping("/auth/login")
        public R login(@RequestBody(required = false) DriverMqttDto mqttDto){

            log.info("====== mqttDto:{}",mqttDto);

            return authService.auth(mqttDto);
    }
}
